import { ApiCall } from "tsrpc";
import { ReqRandom_TitleAtt, ResRandom_TitleAtt } from "../../../../shared/master/bag/function/PtlRandom_TitleAtt";
import { player } from "../../../../model/fight/body/player";
import god from "../../../../god";
import { Tpl_panel_title, template } from "../../../../shared/master/MsgAction";
import { rank_type } from "../../../../shared/interface";

export default async function (call: ApiCall<ReqRandom_TitleAtt, ResRandom_TitleAtt>) {
    call.succ({})
    let user = call.req._player as player;
    let res = user.check_wallet(0, 0, [{ id: 'prop-12', v: 1 }], false, '重新随机称号加成', true);
    if (!res.state) {
        return;
    }
    let add = user.get_DNA_Lv()
    user.title_value = god.getRandomTitleValue(add);
    user.rankLog(rank_type.称号资质,user.title_value.getScore() * 1000)
    let tpl: Tpl_panel_title = {
        style_id: user.style_id,
        style_title_id: user.title_style,
        title_value: user.title_value
    }
    user.sendMsg(template.称号面板,tpl)
}